#ifndef     __SENSOR_H
#define     __SENSOR_H

#include "../../utils/object.h"
#include "../../utils/nocopyable.h"
#include "../../rtos/mutex.h"
#include "../../utils/base.h"

namespace driver {

class Sensor : private utils::NoCopyable {

public: 
    inline bool is_drop() {
        return utils::is_clr_bit<1>(read());
    }

    inline bool is_pick_top() {
        return utils::is_set_bit<2>(read());
    }

    inline bool is_pick_bottom() {
        return utils::is_set_bit<3>(read());
    }

    inline bool is_dump_top() {
        return utils::is_set_bit<4>(read());
    }

    inline bool is_dump_bottom() {
        return utils::is_set_bit<5>(read());
    }

    inline bool is_move_origin() {
        return utils::is_set_bit<6>(read());
    }
    
    inline bool is_cargo_origin() {
        return utils::is_set_bit<7>(read());
    }

    Sensor();

    uint8_t status();

private:
    uint8_t read();

    rtos::Mutex m_mutex;
};

inline utils::Object<Sensor> sensor;

}

#endif
